import { ref  } from 'vue'
import { useRoute } from 'vue-router';
import { defineStore } from 'pinia'
import { userGetInfoService } from '@/api/user'
import { xiaoshuoheard } from '@/api/article';
import { xiaoshuopage } from '@/api/article';
import { xiaoshuocontent } from '@/api/article';
export const userstore = defineStore('user', () => {
  const count = ref('')
  const info=ref({})
  const xiaoshuotitle=ref('')
  const content=ref('')
  const newxiaoshuo=ref('')
 const token=(n)=>{
  count.value=n
 }
 const id=ref('')
 const article=ref(null)
 const newdata=ref('')
 const newdatacontent=ref('')
 const newxiaoshuoinfo=ref('')
//  个人信息
 const getUser = async() => {
  const res = await userGetInfoService() // 请求获取数据
  info.value = res.data.data
}
// 获取接口小说
const xiaoshuo = async()=>{
  const res =await xiaoshuoheard()
  console.log(res.data,'21212');
  xiaoshuotitle.value= res.data
}

const route=useRoute()
const page = async(n)=>{

  const res =await xiaoshuopage(n)
  console.log(res,'dwadwa');
  content.value=res.data
  // console.log(content.value,'3333');
}
const pagecontent= async(id)=>{
  console.log(id,'212121');
 const res = await xiaoshuocontent(id)
//  console.log(res);
 article.value=res
//  console.log(article,'21212');
}

  return { count, token,getUser,info,xiaoshuotitle,xiaoshuo ,page,content,pagecontent,id,article,newdata,newxiaoshuo,newdatacontent,newxiaoshuoinfo}
},
{
  persist: true,
})
